package com.project.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class AddUserFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) servletRequest;
        Object logObj = req.getSession().getAttribute("logUser");
        if(logObj == null){
            servletResponse.getWriter().print("noLogin");
        }
        else {
            filterChain.doFilter(servletRequest,servletResponse);
        }
    }
}
